package com.cy.pj.module.web;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doHandleArithmeticException(ArithmeticException e){
        e.printStackTrace();
        return "计算异常："+e.getMessage();
    }

    @ExceptionHandler(Throwable.class)
    @ResponseBody
    public String doHandleThrowable(Throwable e){
        e.printStackTrace();
        System.out.println("GlobalExceptionHandler.doHandleThrowable");
        return "系统维护中";
    }
}
